/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('safconsole', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model RevokeFeedbackRequest {
  sampleType?: string(name='SampleType'),
  value?: string(name='Value'),
}

model RevokeFeedbackResponseBody = {
  code?: string(name='Code'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model RevokeFeedbackResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: RevokeFeedbackResponseBody(name='body'),
}

async function revokeFeedbackWithOptions(request: RevokeFeedbackRequest, runtime: Util.RuntimeOptions): RevokeFeedbackResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.sampleType)) {
    body['SampleType'] = request.sampleType;
  }
  if (!Util.isUnset(request.value)) {
    body['Value'] = request.value;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'RevokeFeedback',
    version = '2021-01-12',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function revokeFeedback(request: RevokeFeedbackRequest): RevokeFeedbackResponse {
  var runtime = new Util.RuntimeOptions{};
  return revokeFeedbackWithOptions(request, runtime);
}

model SendFeedbackRequest {
  riskLabel?: string(name='RiskLabel'),
  sampleType?: string(name='SampleType'),
  value?: string(name='Value'),
}

model SendFeedbackResponseBody = {
  code?: int32(name='Code'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model SendFeedbackResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: SendFeedbackResponseBody(name='body'),
}

async function sendFeedbackWithOptions(request: SendFeedbackRequest, runtime: Util.RuntimeOptions): SendFeedbackResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.riskLabel)) {
    query['RiskLabel'] = request.riskLabel;
  }
  if (!Util.isUnset(request.sampleType)) {
    query['SampleType'] = request.sampleType;
  }
  if (!Util.isUnset(request.value)) {
    query['Value'] = request.value;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'SendFeedback',
    version = '2021-01-12',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function sendFeedback(request: SendFeedbackRequest): SendFeedbackResponse {
  var runtime = new Util.RuntimeOptions{};
  return sendFeedbackWithOptions(request, runtime);
}

model UploadSampleApiRequest {
  dataType?: string(name='DataType', example='ip'),
  dataValue?: string(name='DataValue', example='["123.124.125.126","123.124.125.127"]'),
  sampleType?: string(name='SampleType', example='block'),
  service?: string(name='Service', example='account_abuse,coupon_abuse,account_takeover'),
}

model UploadSampleApiResponseBody = {
  code?: string(name='Code'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', description='Id of the request', example='4A91D2D1-AEC9-1658-ABCE-5A39DE66A5C2'),
  success?: string(name='Success'),
}

model UploadSampleApiResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: UploadSampleApiResponseBody(name='body'),
}

async function uploadSampleApiWithOptions(request: UploadSampleApiRequest, runtime: Util.RuntimeOptions): UploadSampleApiResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.dataType)) {
    query['DataType'] = request.dataType;
  }
  if (!Util.isUnset(request.dataValue)) {
    query['DataValue'] = request.dataValue;
  }
  if (!Util.isUnset(request.sampleType)) {
    query['SampleType'] = request.sampleType;
  }
  if (!Util.isUnset(request.service)) {
    query['Service'] = request.service;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'UploadSampleApi',
    version = '2021-01-12',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function uploadSampleApi(request: UploadSampleApiRequest): UploadSampleApiResponse {
  var runtime = new Util.RuntimeOptions{};
  return uploadSampleApiWithOptions(request, runtime);
}

